package com.rc.evcharger.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Knife4jConfig
 * Created by yang on 2022/03/24
 */
@Configuration
@EnableSwagger2
@EnableKnife4j
public class Knife4jConfig {

//    <!--    阿里云仓库地址：https://developer.aliyun.com/mvn/search-->

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .useDefaultResponseMessages(false)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.rc.evcharger.controller"))
                .paths(PathSelectors.any())
                .build();

    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .description("访问地址: http://localhost:8082/doc.html")
                .contact(new Contact("peter", "https://github.com.lenve", "347265937@qq.com"))
                .version("v1.1.0")
                .title("API测试文档")
                .build();
    }

}